<?php
/**
 * Remove a document from a ressource 
 * @package Ressource
 */

$id = Xview::instance()->val("missionid");
if(empty($id))
{
	Xview::instance()->systemError();exit;
}
try {
	$object = new Hive\Mission($id);
	$tabLabel = Msg(Hive::BUNDLE,25,$object->title);
}
catch (Fox\Object\Exception\NotExist $e)
{
	Xview::instance()->systemError();exit;
}
if( Xview::instance()->val("confirmation"))
{
	try {
		$object->delete();
		echo Fox\Message::Information(Msg(Fox::MSGCL,Fox\Msg::MSG_DELETE,$tabLabel));
		exit;
	}
	catch (Fox\Object\Exception\Save $e)
	{
		Fox\Message::Error($e->getMessage());
	}
}

$reload = "Refresh(\'?mod=missions&act=search\');";
$yesAction = "FoxPostForm('deleteForm','?mod=missions&act=delete&missionid=$id','$reload',null,null,null,'&confirmation=true')";
$popup = new Fox\Popup\ToConfirm("deleteForm",Msg(Fox\MSg::BUNDLE,Fox\Msg::MSG_DELETE_HDR), Msg(Hive::BUNDLE,24,$tabLabel),$yesAction,null,470);
echo $popup->Display();